package cn.t.converter.device;

import cn.t.core.converter.CoreDTOConverter;
import cn.t.dto.device.DeviceDTO;
import cn.t.model.device.CargowayDO;
import cn.t.model.device.CargowaySkuDO;
import cn.t.model.device.DeviceDO;
import cn.t.model.sku.SkuDO;
import cn.t.request.CreateDeviceReq;
import cn.t.request.DeviceConfigReq;
import cn.t.request.OnOffShelfReq;
import cn.t.vo.HardwareConfigDetailVO;
import cn.t.vo.HardwareConfigVO;
import cn.t.vo.device.DeviceBaseInfoVO;
import cn.t.vo.device.DeviceConfigVO;
import cn.t.vo.device.DeviceDetailVO;
import cn.t.vo.device.DeviceVO;
import cn.t.vo.device.InventoryCargowayExcelVO;
import cn.t.vo.device.InventoryCargowayVO;
import cn.t.vo.device.InventoryDeviceExcelVO;
import cn.t.vo.device.InventoryDeviceVO;
import cn.t.vo.device.InventorySkuExcelVO;
import cn.t.vo.device.InventorySkuVO;
import cn.t.vo.ent.EntDeviceDetailVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * 设备表(Device)dto转domain
 *
 * @author t
 * @since 2024-05-24 10:19:33
 */
@Mapper(componentModel = "spring")
public interface DeviceDTOConverter extends CoreDTOConverter<DeviceDTO, DeviceDO> {

    DeviceDO createParam2do(CreateDeviceReq request, CreateDeviceReq.DeviceInfo deviceInfo, String imei, String pin);


    @Mapping(target = "deviceId", source = "id")
    @Mapping(target = "cargowayNum", source = "cargowayQty")
    DeviceVO do2Vo(DeviceDO deviceDO);
    List<DeviceVO> do2Vo(List<DeviceDO> deviceDOS);

    @Mapping(target = "id", source = "deviceId")
    DeviceDO configReq2Do(DeviceConfigReq req);

    @Mapping(target = "deviceId", source = "deviceDO.id")
    @Mapping(target = "lastConnectTime", source = "deviceDO.gmtConnect")
    @Mapping(target = "firmName", source = "firmName")
    DeviceConfigVO do2ConfigVo(DeviceDO deviceDO, String firmName);

    @Mapping(target = "deviceId", source = "id")
    @Mapping(target = "createTime", source = "gmtCreated")
    HardwareConfigVO do2HardwareConfigVo(DeviceDO deviceDO);
    List<HardwareConfigVO> do2HardwareConfigVo(List<DeviceDO> deviceDOS);

    @Mapping(target = "skuCode", source = "sku.skuCode")
    @Mapping(target = "id", source = "request.cargowaySkuId")
    @Mapping(target = "gmtCreated", ignore = true)
    @Mapping(target = "gmtModified", ignore = true)
    @Mapping(target = "creator", ignore = true)
    @Mapping(target = "modifier", ignore = true)
    @Mapping(target = "isDeleted", ignore = true)
    @Mapping(target = "weight", ignore = true)
    @Mapping(target = "skuWeight", source = "sku.weight")
    @Mapping(target = "skuId", source = "sku.id")
    CargowaySkuDO req2CargowaySku(SkuDO sku, OnOffShelfReq request);

    @Mapping(target = "cargowayId", source = "cargowayDO.id")
    HardwareConfigDetailVO.CargowayDetail data2HardwareConfigDetailVO(CargowayDO cargowayDO, String ctrlBoardNo);

    @Mapping(target = "deviceId", source = "id")
    @Mapping(target = "deviceTypeName", expression = "java(cn.t.enums.device.DeviceTypeEnum.getName(deviceDO.getDeviceType()))")
    DeviceBaseInfoVO do2BaseInfoVo(DeviceDO deviceDO);

    EntDeviceDetailVO detailVo2EntDetailVo(DeviceDetailVO deviceDetailVO);

    List<InventoryDeviceExcelVO> deviceVO2ExcelVO(List<InventoryDeviceVO> inventoryDeviceVOS);

    List<InventorySkuExcelVO> skuVO2ExcelVO(List<InventorySkuVO> inventorySkuVOs);

    List<InventoryCargowayExcelVO> cargowayVO2ExcelVO(List<InventoryCargowayVO> inventoryCargowayVOS);
}

